home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / tlxutl10.zip / SETCOL.PAS < prev    next >
Pascal/Delphi Source File  |  1991-01-25  |  2KB  |  101 lines

  1. Program SetColours;
  2.  
  3. { Copyright 1991 By Reuben Sumner }
  4.  
  5. Uses
  6.     Dos;
  7.  
  8. Const
  9.     LookFor : Array [1..12] of String[10] =
  10.         ('deffg','defbg','statfore','statback','bord','mbord','mbback',
  11.         'mfore','mbold','mback','mbar','msel');
  12. { This is an array of strings to search for in config file that indicate
  13.     that they are colours }
  14.  
  15. Var
  16.     Config, Salt : PathStr;
  17.     CNF, SLT, New : Text;
  18.  
  19.     Colours : Array [1..12] of Byte;
  20.     FDir : DirStr;
  21.     FName : NameStr;                    { Strings for breaking up filenames }
  22.     FExt : ExtStr;
  23.  
  24.     Line : String[80];                { Line to read in from files }
  25.     Temp : String[3];
  26.     Count, Position : Byte;            { Count : For loop purposes
  27.                                             Position : variable for location of = sign
  28.                                             and other }
  29.     Name : String[10];                { Name of line in config ie "bord" }
  30.     Value : String[40];                { Value for Name ie 10 or "ATDT" }
  31.     Error : Integer;                    { Result code for Val procedure }
  32.  
  33. Begin
  34.     If ParamCount <> 2 Then Begin
  35.         WriteLn ('Improper syntax!');
  36.         WriteLn;
  37.         WriteLn ('Correct syntax is:');
  38.         WriteLn ('SETCOL [config[.CNF] file[.SLT]]');
  39.     End
  40.     Else Begin
  41.         Config := ParamStr (1);
  42.         Salt := ParamStr (2);
  43.  
  44.         FSplit (Config,FDir,FName,FExt);
  45.         If FExt = '' Then
  46.             FExt := '.CNF';
  47.         Config := FDir + FName + FExt;
  48.         Assign (CNF,Config);
  49.         Reset (CNF);
  50.  
  51.         FSplit (Salt,FDir,FName,FExt);
  52.         If FExt = '' Then
  53.             FExt := '.SLT';
  54.         Salt := FDir + FName + FExt;
  55.         Assign (SLT,Salt);
  56.  
  57.         FSplit (Salt,FDir,FName,FExt);
  58.         FExt := 'bak';
  59.         Assign (New,FDir+FName+'.'+FExt);
  60.         {$I-}
  61.         Erase (New);
  62.         {$I+}
  63.         Error := IOResult; { Never used but clears result code }
  64.         Assign (New,Salt);
  65.         Rename (SLT,FDir+FName+'.'+FExt);
  66.         Repeat
  67.             ReadLn (CNF,Line);
  68.             Count := 1;
  69.             Position := Pos ('=',Line);
  70.             Name := Copy (Line,1,Position-1);
  71.             Value := Copy (Line,Position+1,Length(Line)-Position);
  72.             Repeat
  73.                 If Name = LookFor [Count] Then Begin
  74.                     Val (Value,Colours[Count],Error);
  75.                     Count := 12;
  76.                 End;
  77.                 Inc (Count);
  78.             Until Count = 13;
  79.         Until Eof(CNF);
  80.         Close (CNF);
  81.  
  82.         Reset (SLT);
  83.         Rewrite (New);
  84.  
  85.         Repeat
  86.             ReadLn (SLT,Line);
  87.             Repeat
  88.                 Position := Pos (#1,Line);
  89.                 If Position <> 0 Then Begin
  90.                     Str (Colours[Ord(Line[Position+1])],Temp);
  91.                     Delete (Line,Position,2);
  92.                     Insert (Temp,Line,Position);
  93.                 End;
  94.             Until Position = 0;
  95.             WriteLn (New,Line);
  96.         Until Eof (SLT);
  97.         Close (New);
  98.         Close (SLT);
  99.     End;
  100. End.
  101.